Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

279
Vistas
Mysql "Select mod(col1, 10) ... " generates bigint. How to make it to be int type

I have following code

String sql = "(select mod_col, 1 as count_col from ( " +
                    "select mod(col1, 10) as mod_col " +
                    "from table1 c " +
                    "where c.col2 = 1) temp " +
                    "group by mod_col, count_col ) as temp2";

DataFrame df = getDSEDataFrame(sql);

Note that the col1 is defined in mysql with type int(11) NOT NULL.

However, when I check the df, the mod_col has the correct value as a bigint. This cause an exception java.math.BigDecimal cannot be cast to java.lang.Integer for my following code

        List<Row> col1List = df.collectAsList();

        for (Row r : col1List) {
             Integer col1Val = r.getAs("mod_col");  // exception thrown here
        }

Is there any way in above sql that I can force it return an integer instead of a big integer?

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda